﻿using BusinessLayer.Dal;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace Biz
{
    public class Property
    {
        [Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }
        public virtual Category Category { get; set; }

        PropertyDal dal = new PropertyDal(); 
        public void Insert()
        {
            dal.Insert(this);
        }

        public void Update()
        {
            dal.Update(this);
        }

        public void Delete()
        {
            dal.Delete(this);
        }
        public override string ToString()
        {
            return Name;
        }

        public static List<Property> GetByCategory(Category cat)
        {
            return PropertyDal.GetByCategory(cat);
        }
    }
}